package org.lisen.nginxcors.config;

import org.lisen.nginxcors.annotation.ApiRestController;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.PathMatchConfigurer;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import javax.annotation.Resource;

/**
 * @author laughing
 * @date 2020/9/26
 * @site https://www.lisen.org
 */
@Configuration
public class MyWebMvcConfig implements WebMvcConfigurer {

    @Resource
    RequestPathProperties requestPathProperties;

    @Override
    public void configurePathMatch(PathMatchConfigurer configurer) {
        configurer.addPathPrefix(requestPathProperties.getApiPath(), c->c.isAnnotationPresent(ApiRestController.class));
    }
}
